package com.sigmatrix.h5.dao.impl;

import org.springframework.stereotype.Repository;

import com.sigmatrix.h5.dao.DisTerminalShopDetailDao;
import com.sigmatrix.h5.entity.DisTerminalShopDetail;
import com.sigmatrix.h5.utils.Constants;
import com.sigmatrix.sc.jdbc.common.dao.DaoImpl;

/**
 * 
 *@ClassName: DisTerminalShopDetailDaoImpl
 *@Description: 终端门店跟经销商对应表
 *@author MH
 *@date 2017年12月5日 下午1:32:28
 */
@Repository
public class DisTerminalShopDetailDaoImpl extends DaoImpl<DisTerminalShopDetail,Integer> implements DisTerminalShopDetailDao{

	@Override
	public int selectCountByTerminalNameAndDealerId(String terminalName, Integer dealerId) {
		StringBuffer sql = new StringBuffer();
		sql.append("select count(1) from ").append(tableName());
		sql.append(" where _terminal_shop_name = N'").append(terminalName).append("'");
		sql.append(" and _status <> ").append(Constants.STATUS_DELETE);
		sql.append(" and _dealer_id = ").append(dealerId);
		logger.info("sql="+sql);
		return jdbcTemplate.queryForObject(sql.toString(), Integer.class);
	}

}
